YAHOO.namespace('ext.Vector');
YAHOO.ext.Vector.PathToBaseScripts = '';
/**
 * @class YAHOO.ext.Vector.VectorManager
 * This class is a singleton that manages vector objects 
 */
YAHOO.ext.Vector.VectorManager = new function(){
	var brows = YAHOO.ext.util.Browser;
	var vectorType = 'vml';  //vml or svg
	/**
	 * Sets up required vector graphics options per browser
	 */
	this.setupVector = function(){
		var baseHtml = document.getElementsByTagName('html')[0];
		var baseHead = document.getElementsByTagName('head')[0];
		var htmlNS = '';
		var htmlNSText = '';
		var vectorBase = '';
		if(brows.isIE||brows.isIE7){
			vectorBase = 'BaseVml.js';
			htmlNS = 'xmlns:v';
			htmlNSText = 'urn:schemas-microsoft-com:vml';
			var cssStr = 'v\\:* { behavior: url(#default#VML); }';
			var style = document.createElement("style");
			style.setAttribute("type", "text/css");
			style.styleSheet.cssText = cssStr;
			baseHead.appendChild(style);
			vectorType = 'vml';
		}else{
			vectorBase = 'BaseSVG.js';
			htmlNS = 'xmlns';
			htmlnstext = 'http://www.w3.org/1999/xhtml';
			vectorType = 'svg';
			var meta=document.createElement("meta");
		    meta.setAttribute("http-equiv","Content-Type");
		    meta.setAttribute("content","application/xhtml+xml");
		    baseHead.appendChild(meta);
		}
		baseHtml.setAttribute(htmlNS,htmlNSText);	
		var base = document.createElement('script');
		base.setAttribute('src', YAHOO.ext.Vector.PathToBaseScripts + vectorBase);
		baseHead.appendChild(document.createElement('script'))
	}
	this.getLine = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.Line(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.Line(renderTo, config);
		}
	}
	this.getPoly = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.Polyline(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.Polyline(renderTo,config);
		}
	}
	this.getBox = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.Box(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.Box(renderTo, config);	
		}
	}
	this.getGroup = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.Group(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.Group(renderTo,config);
		}
	}
	this.getRoundBox = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.RoundBox(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.RoundBox(renderTo,config);
		}
	}
	this.getRoundBox = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.RoundBox(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.RoundBox(renderTo,config);
		}
	}
	this.getImage = function(renderTo, config){
		if(vectorType == 'vml'){
			return new YAHOO.ext.Vector.Image(renderTo, config);
		}else{
			return new YAHOO.ext.SVG.Image(renderTo,config);
		}
	}
}
YAHOO.ext.EventManager.onDocumentReady(YAHOO.ext.Vector.VectorManager.setupVector, YAHOO.ext.Vector.VectorManager, true);